home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / capbowl.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  2KB  |  108 lines

  1. /***************************************************************************
  2.  
  3.   machine.c
  4.  
  5.   Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
  6.   I/O ports)
  7.  
  8. ***************************************************************************/
  9.  
  10. #include "driver.h"
  11. #include "machine/ticket.h"
  12.  
  13. static int currentaddress = 0;
  14. static int GRHighByte = 0;
  15. static int GRMidByte  = 0;
  16. static int GRLowByte = 0;
  17.  
  18. void capbowl_init_machine(void)
  19. {
  20.     /* Initialize the ticket dispenser to 100 milliseconds */
  21.     /* (I'm not sure what the correct value really is) */
  22.     ticket_dispenser_init(100, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_LOW);
  23. }
  24.  
  25.  
  26. WRITE_HANDLER( capbowl_rom_select_w )
  27. {
  28.     int bankaddress = 0x10000 + ((data & 0x0c) << 13) + ((data & 0x01) << 14);
  29.     unsigned char *RAM = memory_region(REGION_CPU1);
  30.  
  31.  
  32.     cpu_setbank(1,&RAM[bankaddress]);
  33. }
  34.  
  35.  
  36. /*
  37.     Write to GR Address upper word (2 bits)
  38. */
  39. WRITE_HANDLER( bowlrama_turbo_w )
  40. {
  41.     switch( offset )
  42.     {
  43.         case 0x08:      /* Write address high byte (only 2 bits used) */
  44.             GRHighByte = data;
  45.             break;
  46.  
  47.         case 0x17:    /* Write address mid byte (8 bits)   */
  48.             GRMidByte = data;
  49.             break;
  50.  
  51.         case 0x18:      /* Write Address low byte (8 bits)   */
  52.             GRLowByte = data;
  53.             break;
  54.  
  55.         default:
  56.             logerror("PC=%04X Write to unsupported Turbo address %02X Data=%02X\n",cpu_get_pc(),offset, data);
  57.     }
  58.  
  59.     currentaddress = ((GRHighByte << 16) | (GRMidByte << 8) | GRLowByte);
  60. }
  61.  
  62.  
  63. READ_HANDLER( bowlrama_turbo_r )
  64. {
  65.     int ret = 0;
  66.     int data = memory_region(REGION_GFX1)[currentaddress];
  67.  
  68.     switch (offset)
  69.     {
  70.     case 0:    /* Read Mask */
  71.  
  72.         /*  Graphics data are 4bpp (2 pixels per byte).
  73.             This function returns 0's for new pixel data.
  74.             This allows data to be read as a mask, AND the mask with
  75.             the screen data, then OR new data read by read data command.
  76.         */
  77.  
  78.         if(!(data & 0xf0))
  79.         {
  80.             ret = 0xf0;  /* High nibble is transparent */
  81.         }
  82.  
  83.         if(!(data & 0x0f))
  84.         {
  85.             ret |= 0x0f;  /* Low nibble is transparent */
  86.         }
  87.  
  88.         break;
  89.  
  90.     case 4: /* Read data and increment address */
  91.  
  92.         ret    = data;
  93.  
  94.         currentaddress = (currentaddress + 1) & 0x3ffff;
  95.  
  96.         GRHighByte = (currentaddress >> 16);
  97.         GRMidByte  = (currentaddress >> 8) & 0xff;
  98.         GRLowByte  = (currentaddress & 0xff);
  99.  
  100.         break;
  101.  
  102.     default:
  103.         logerror("PC=%04X Read from unsupported Turbo address %02X\n",cpu_get_pc(),offset);
  104.     }
  105.  
  106.     return ret;
  107. }
  108.